<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>获取当前位置:</h1>
    <h3>经度:<span id="jspan"></span></h3>
    <h3>纬度:<span id="wspan"></span></h3>
    <script>
        let geoloc=window.navigator.geolocation;
        // geoloc.getCurrentPosition((suc)=>{
         geoloc.watchPosition((suc)=>{
            console.log(suc);
            let jspan=document.getElementById('jspan');
            jspan.innerHTML=suc.coords.longitude
            let wspan=document.getElementById('wspan');
            wspan.innerHTML=suc.coords.latitude
        },(err)=>{
            console.log(err);
        },{
            timeout:5000
        })
    </script>
</body>
</html>